/*
 * @Description: 原文挂接
 * @Author: Rfan
 * @Date: 2022-05-04 19:07:54
 * @LastEditTime: 2022-05-23 15:25:05
 */

import { useEffect } from 'react';
import { Button, Modal, Tabs } from 'antd';
import type { FC } from 'react';
import RulePane from './components/RulePane';
import type { ICommonDialog } from '@/interfaces/global';
import UploadPane from './components/UploadPane';
import { useBatchManageContext } from '../../../contexts/BatchManageContext';

interface UploadOriginDialogProps extends ICommonDialog {}

const { TabPane } = Tabs;

const UploadOriginDialog: FC<UploadOriginDialogProps> = (props) => {
  const { visible, onClose } = props;
  const { activeBatch } = useBatchManageContext();

  useEffect(() => {
    if (visible) {
      console.log('UploadOriginDialog', activeBatch);
    }
  }, [visible]);

  const onCancel = () => {
    onClose();
  };

  return (
    <Modal
      title="原文批量挂接"
      visible={visible}
      className="upload-origin-dialog"
      width={600}
      maskClosable={false}
      destroyOnClose
      onCancel={onCancel}
      footer={[
        <Button key="close" onClick={onCancel}>
          关闭
        </Button>
      ]}
    >
      <p>
        当前批次档案为：全宗{activeBatch.fonds?.fondName} - 档案类型
        {activeBatch.archiveType?.atName}
      </p>
      <Tabs>
        <TabPane tab="原文导入规则" key={1}>
          <RulePane
            batchId={activeBatch.id}
            atId={activeBatch.archiveTypeId}
            rule={activeBatch.attOriginalRule}
          />
        </TabPane>
        <TabPane tab="上传原文" key={2}>
          <UploadPane
            batchId={activeBatch.id}
            atId={activeBatch.archiveTypeId}
            rule={activeBatch.attOriginal}
          />
        </TabPane>
      </Tabs>
    </Modal>
  );
};

export default UploadOriginDialog;
